<template>
  <div class="chat-window">
    <div
      v-for="(item, index) in chatList"
      :key="index"
      :class="['chat-bubble', item.role]"
    >
      <div class="bubble-content">
        {{ item.text }}
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps } from 'vue';

const props = defineProps({
  chatList: {
    type: Array,
    required: true
  }
});
</script>

<style scoped>
.chat-window {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 20px 0;
  width: 100%;
}

.chat-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.chat-bubble.user {
  align-self: flex-end;
  background-color: #e5f0fe;
  color: #333;
  margin-left: 20%;
}

.chat-bubble.ai {
  align-self: flex-start;
  background-color: #f5f7fa;
  color: #333;
  margin-right: 20%;
  border: 1px solid #e4e7ed;
}

.bubble-content {
  position: relative;
  z-index: 1;
}
</style>
